<?php
/**
 * @version $Id: api.php 20 2011-01-20 07:55:28Z jayeeliu@gmail.com $
 * @version $Revsion$
 */
define('WEB_ROOT', 	dirname(__FILE__));
define('APP_ROOT', 	WEB_ROOT . '/app');
define('TPL_ROOT', 	APP_ROOT . '/tpl');
define('WEB_URL', 	dirname("http://{$_SERVER['HTTP_HOST']}{$_SERVER['PHP_SELF']}"));


require WEB_ROOT . '/inc/config.php';
require WEB_ROOT . '/inc/lib.php';
require WEB_ROOT . '/inc/errcode.conf.php';
require WEB_ROOT . '/inc/s.php';
S::import(APP_ROOT.'/api');
S::import(APP_ROOT.'/module');

$controller	= trim($_GET['c']);
$action		= trim($_GET['act']);

if ($controller != 'user' || $action != 'login') {
	user::login();
}

try {
	new $controller();
} catch (Exception $e) {
	e('{"ret":"err"}');
}

function _u($key) {
	return $_COOKIE[$key];
}
